package com.atguigu.bigdata.spark.core.rdd.operator.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
  * create by undeRdoG on  2021-06-08  14:26
  * 凡心所向，素履以往，生如逆旅，一苇以航。
  */
object Spark07_RDD_Operator_Transform_Test {

  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setAppName("Operator").setMaster("local[*]")
    val sc = new SparkContext(sparkConf)

  /**
  *  只保留 2015-05-17 的数据
  * */
    val log: RDD[String] = sc.textFile("datas/apache.log")

    val timeRDD: RDD[String] = log.map(line => {
      val fields: Array[String] = line.split(" ")
      fields(3)
    })
    val res: RDD[String] = timeRDD.filter(time => time.startsWith("17/05/2015"))

    res.collect().foreach(println)
  }
}
